import { createI18n } from "vue-i18n";
import { getBrowserLang } from "@/utils";

console.log(getBrowserLang());
import zh from "./modules/zh";
import en from "./modules/en";
import kr from "./modules/kr";
const datetimeFormats = {
  en: {
    long: {
      year: "numeric",
      month: "short",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      hourCycle: "h12"
    },
    short: {
      year: "2-digit",
      month: "numeric",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      hourCycle: "h12"
    }
  },
  "ko-KR": {
    long: {
      year: "numeric",
      month: "short",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      hourCycle: "h12"
    },
    short: {
      year: "2-digit",
      month: "numeric",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      hourCycle: "h12"
    }
  },
  "ms-MY": {
    long: {
      year: "numeric",
      month: "short",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      hourCycle: "h12"
    },
    short: {
      year: "2-digit",
      month: "numeric",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      hourCycle: "h12"
    }
  },
  "vi-VN": {
    long: {
      year: "numeric",
      month: "short",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      hourCycle: "h12"
    },
    short: {
      year: "2-digit",
      month: "numeric",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      hourCycle: "h12"
    }
  },
  zh: {
    long: {
      year: "numeric",
      month: "long",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      hourCycle: "h24"
    },
    short: {
      year: "2-digit",
      month: "numeric",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      hourCycle: "h24"
    }
  },
  "zh-tw": {
    long: {
      year: "numeric",
      month: "long",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      second: "numeric",
      hourCycle: "h24"
    },
    short: {
      year: "2-digit",
      month: "numeric",
      day: "numeric",
      hour: "numeric",
      minute: "numeric",
      hourCycle: "h24"
    }
  }
};
const numberFormats = {
  en: {
    currency: {
      style: "currency",
      currency: "USD",
      notation: "standard"
    },
    decimal: {
      style: "decimal",
      minimumFractionDigits: 2,
      maximumFractionDigits: 2
    },
    percent: {
      style: "percent",
      useGrouping: false
    }
  },
  zh: {
    currency: {
      style: "currency",
      currency: "JPY",
      useGrouping: true,
      currencyDisplay: "symbol"
    },
    decimal: {
      style: "decimal",
      minimumSignificantDigits: 3,
      maximumSignificantDigits: 5
    },
    percent: {
      style: "percent",
      useGrouping: false
    }
  }
};
console.log("getBrowserLang", getBrowserLang());
const i18n = createI18n({
  // Use Composition API, Set to false
  allowComposition: true,
  legacy: false,
  locale: getBrowserLang(),
  messages: {
    zh,
    "zh-tw": zh,
    en,
    "ko-KR": kr,
    "ms-MY": kr,
    "vi-VN": kr
  },
  datetimeFormats,
  numberFormats
});

export default i18n;
